function dateFormat(dateInput, format) {
  const year = dateInput.getFullYear();
  const month = dateInput.getMonth() + 1;
  const day = dateInput.getDate();
  format = format.replace(/yyyy/, year);
  format = format.replace(/MM/, month);
  format = format.replace(/dd/, day);
  return format;
}

let res1 = dateFormat(new Date("2020-12-01"), "yyyy/MM/dd"); // 2020/12/01
let res2 = dateFormat(new Date("2020-04-01"), "yyyy/MM/dd"); // 2020/04/01
let res3 = dateFormat(new Date("2020-04-01"), "yyyy年MM月dd日"); // 2020年04月01日

console.log(res1);
console.log(res2);
console.log(res3);
